﻿@model LayoutModel

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>@Model.PageTitle - @Model.WebTitle - Snai.CMS</title>

    <link rel="stylesheet" href="~/lib/layui/css/layui.css">
    <link rel="stylesheet" href="~/css/site.css">
</head>
<body class="layui-layout-body">
    <div class="layui-layout layui-layout-admin">
        <div class="layui-header">
            <div class="layui-logo">@Model.WebTitle</div>
            <!-- 头部区域 -->
            <ul class="layui-nav layui-layout-left">
                @foreach (var module in Model.RoleModules.Where(s => s.ParentID == 0))
                {
                    if (Model.ThisModules.Contains(module.ID))
                    {
                        <li class="layui-nav-item layui-this"><a href="/@module.Controller/@module.Action">@module.Title</a></li>
                    }
                    else
                    {
                        <li class="layui-nav-item"><a href="/@module.Controller/@module.Action">@module.Title</a></li>
                    }
                }
            </ul>
            <ul class="layui-nav layui-layout-right">
                <li class="layui-nav-item">
                    <a href="javascript:;">
                        @Model.UserName &lt;@Model.RoleTitle&gt;
                    </a>
                    <dl class="layui-nav-child">
                        <dd><a href="/Login/AdminLogout">退出</a></dd>
                    </dl>
                </li>
            </ul>
        </div>

        <div class="layui-side layui-bg-black">
            <div class="layui-side-scroll">
                <!-- 左侧导航区域 -->
                <ul class="layui-nav layui-nav-tree">
                    @{ var i = 0; }
                    @foreach (var module in Model.RoleModules.Where(s => s.ParentID == Model.ThisModules.First()))
                    {
                        if (i == 0 && Model.ThisModules.Count() < 2)
                        {
                            @Html.Raw("<li class='layui-nav-item layui-nav-itemed'>")
                        }
                        else if(Model.ThisModules.Contains(module.ID))
                        {
                            @Html.Raw("<li class='layui-nav-item layui-nav-itemed'>")
                        }
                        else
                        {
                            @Html.Raw("<li class='layui-nav-item'>")
                        }
                                <a class="" href="javascript:;">@module.Title</a>
                                @Html.Raw("<dl class='layui-nav-child'>")
                                    foreach (var child in Model.RoleModules.Where(s => s.ParentID == module.ID))
                                    {
                                        if(Model.ThisModules.Contains(child.ID))
                                        {
                                        <dd class="layui-this"><a href="/@child.Controller/@child.Action">@child.Title</a></dd>
                                        }
                                        else
                                        {
                                        <dd><a href="/@child.Controller/@child.Action">@child.Title</a></dd>
                                        }
                                    }
                                @Html.Raw("</dl>")
                            @Html.Raw("</li>")
                            i = i + 1;
                    }
                </ul>
            </div>
        </div>
        <div class="layui-body">
            <!-- 内容主体区域 -->
            <div style="padding: 12px 15px;">
                @Model.PageTitle
                <hr>
                @RenderBody()
            </div>
        </div>

        @await Html.PartialAsync("_Footer")
    </div>
    <script src="~/lib/jquery-3.3.1.min.js"></script>
    <script src="~/lib/layui/layui.js"></script>
    <script src="~/js/layui.element.js"></script>
    @RenderSection("Scripts", required: false)
</body>
</html>
